package flink.serialize;

import org.apache.flink.api.common.serialization.SerializationSchema;

import com.alibaba.fastjson.JSONObject;

/**
 * @author ：Jason
 * @date ：Created in 2023/5/5 12:02 PM
 * @description：
 * @modified By：
 * @version: 1.0
 */
public class KafkaKeySerializeSchema implements SerializationSchema<JSONObject> {
    private final String kafkaKey;

    public KafkaKeySerializeSchema(String kafkaKey) {
        this.kafkaKey = kafkaKey;
    }

    @Override
    public byte[] serialize(JSONObject element) {
        return element.getString(kafkaKey).getBytes();
    }
}
